var t = getApp();

Page({
    data: {
        Wshow: !1,
        _num: 0,
        grouping: !1,
      groups:[
        {
          userId:1,
          userIcon: '/assets/images/head.png',
          name:'小花',
          remarkName:'小明'
        },
        {
          userId: 1,
          userIcon: '/assets/images/head.png',
          name: '小花',
          remarkName: '小明'
        },
        {
          userId: 1,
          userIcon: '/assets/images/head.png',
          name: '小花',
          remarkName: '小明'
        }
      ]
    },
    shu: function(a) {
        // console.log(a.currentTarget.dataset.patientid), wx.request({
        //     url: t.globalData.dic + "doctor/manage/showPatientAllowArchives/" + a.currentTarget.dataset.patientid,
        //     success: function(t) {
        //         if (console.log(t.data.data), 1 != t.data.data) wx.showModal({
        //             title: "提示",
        //             content: "患者没有授权",
        //             success: function(t) {
        //                 t.confirm ? console.log("用户点击确定") : t.cancel && console.log("用户点击取消");
        //             }
        //         }); else {
        //             wx.setStorageSync("patientId", a.currentTarget.dataset.patientid);
        //             var e = wx.getStorageSync("teamId") || "";
        //             wx.setStorageSync("flag", "2"), wx.navigateTo({
        //                 url: "/hyb_yl/backstageFollowUp/pages/healthRecord/healthRecord?teamId=_" + e
        //             });
        //         }
        //     }
        // });
      wx.navigateTo({
        url: "/hyb_yl/backstageFollowUp/pages/healthRecord/healthRecord"
      });
    },
    menuClick: function(t) {
        console.log(t.target.dataset), this.setData({
            _num: t.target.dataset.num,
            nmDisReason: t.target.dataset.text,
            cdDisReason: t.target.dataset.uuid
        });
    },
    wzconfirm: function(a) {
        var e = this, o = wx.getStorageSync("log") || "", n = wx.getStorageSync("teamId") || "";
        wx.request({
            url: t.globalData.dic + "doctor/team/sign/break",
            data: {
                token: o,
                patientId: e.data.patientid,
                teamId: n,
                cdDisReason: e.data.cdDisReason,
                nmDisReason: e.data.nmDisReason
            },
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                console.log(t.data), 200 == t.data.code && (e.setData({
                    Wshow: !1
                }), e.onClock());
            }
        });
    },
    call: function(t) {
        this.setData({
            Wshow: !1
        });
    },
    Wmovement: function(a) {
        s = this;
        console.log("移动，解约");
        var e = a.currentTarget.dataset.patientid, o = wx.getStorageSync("log") || "", n = wx.getStorageSync("teamId") || "", s = this;
        wx.showActionSheet({
            itemList: [ "移动到分组", "移出分组", "解除签约", "修改备注" ],
            success: function(c) {
                0 == c.tapIndex ? 1 == s.data.managerRole || 2 == s.data.managerRole ? (wx.setStorageSync("patientid", e), 
                wx.navigateTo({
                  url: "/hyb_yl/backstageServicess/pages/management1/management1"
                })) : wx.showToast({
                    title: "暂无权限",
                    icon: "none",
                    duration: 2e3
                }) : 1 == c.tapIndex ? 1 == s.data.managerRole || 2 == s.data.managerRole ? wx.request({
                    url: t.globalData.dic + "doctor/team/manage/group/movePatient",
                    data: {
                        token: o,
                        patientId: e,
                        teamId: n
                    },
                    method: "POST",
                    header: {
                        "Content-Type": "application/x-www-form-urlencoded"
                    },
                    success: function(t) {
                        console.log(t.data), s.onClock();
                    }
                }) : wx.showToast({
                    title: "暂无权限",
                    icon: "none",
                    duration: 2e3
                }) : 2 == c.tapIndex ? 1 == s.data.managerRole || 2 == s.data.managerRole ? s.setData({
                    Wshow: !0,
                    patientid: e
                }) : wx.showToast({
                    title: "暂无权限",
                    icon: "none",
                    duration: 2e3
                }) : 3 == c.tapIndex && (wx.setStorageSync("patientid", a.currentTarget.dataset.patientid), 
                wx.setStorageSync("wznameModifier", a.currentTarget.dataset.name), wx.navigateTo({
                        url: "/hyb_yl/backstageServicess/pages/casControlname1/casControlname1"
                }));
            }
        });
    },
    onClock: function(a) {
        var e = this, o = wx.getStorageSync("log") || "", n = wx.getStorageSync("groupid") || "", s = wx.getStorageSync("managerRole") || "";
        wx.request({
            url: t.globalData.dic + "doctor/team/manage/listPatientByGroup/" + o + "/" + n,
            success: function(t) {
                console.log(t.data.data), t.data.data.length <= 0 ? e.setData({
                    grouping: !0
                }) : e.setData({
                    grouping: !1
                }), e.setData({
                    groups: t.data.data,
                    managerRole: s
                });
            }
        });
    },
    onLoad: function(a) {
        // var e = this, o = wx.getStorageSync("wzname") || "";
        // wx.setNavigationBarTitle({
        //     title: o
        // }), wx.request({
        //     url: t.globalData.dicc + "dic/comdicbase",
        //     data: {
        //         code: 38e4
        //     },
        //     success: function(t) {
        //         console.log(t.data.data);
        //         var a = t.data.data, o = [], n = [];
        //         for (var s in a) o.push(a[s]), n.push(s);
        //         console.log(o[0]), e.setData({
        //             text: o,
        //             textID: n,
        //             cdDisReason: n[0],
        //             nmDisReason: o[0]
        //         });
        //     }
        // }), e.onClock();
    },
    onShow: function() {
        // this.onClock();
    }
});